{
 "cells": [
  {
   "metadata": {},
   "cell_type": "markdown",
   "source": "Pygame Locals 模块",
   "id": "a9c4491907fecfc6"
  },
  {
   "metadata": {},
   "cell_type": "markdown",
   "source": [
    "这个模块包含了在Pygame应用程序中经常使用的各种常量的定义。尽管这些常量是在各自的模块中定义的，但在locals模块中使用它们会更方便。\n",
    "\n",
    "例如，按键或鼠标事件（如KEYDOWN或MOUSEBUTTONDOWN）分别定义为pygame.key.KEYDOWN或pygame.mouse.MOUSEBUTTON，通过从locals模块导入，这些常量可以不用限定模块名称。\n",
    "\n",
    "这里，我们使用来自locals模块的QUIT事件。"
   ],
   "id": "da9682441bf3c317"
  },
  {
   "metadata": {},
   "cell_type": "code",
   "outputs": [],
   "execution_count": null,
   "source": [
    "import pygame,sys\n",
    "from pygame.locals import *\n",
    "pygame.init()\n",
    "canvas=pygame.display.set_mode((400,300))\n",
    "pygame.display.set_caption(\"Hello\")\n",
    "canvas.fill((0,0,0))\n",
    "while True:\n",
    "   for event in pygame.event.get():\n",
    "      if(event.type == QUIT):\n",
    "         pygame.quit()\n",
    "            sys.exit(1)"
   ],
   "id": "98c3a449432640d7"
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
